package cate.game.play.vo;

import cate.game.play.fighter.HeroFighter;
import cate.game.play.fighter.PetFighter;
import cate.game.play.part.FightTeam;
import easy.java.dev.note.NoteField;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FightTeamVO {

	@NoteField("队伍")
	public byte team;

	@NoteField("圣器")
	public HallowFighterVO hallow;

	@NoteField("副圣器")
	public HallowFighterVO deputyHallow;

	@NoteField("灵宠")
	public Map<Integer,PetFighterVO> pets;

	@NoteField("队伍中的英雄")
	public List<HeroFighterVO> heros = new ArrayList<>();

	public FightTeamVO read(FightTeam fightTeam) {
		this.team = fightTeam.team;
		if (fightTeam.hallow != null) {
			this.hallow = new HallowFighterVO().read(fightTeam.hallow);
		}
		if (fightTeam.deputyHallow != null) {
			this.deputyHallow = new HallowFighterVO().read(fightTeam.deputyHallow);
		}
		if (fightTeam.pets != null) {
			pets = new HashMap<>();
			for (Map.Entry<Integer, PetFighter> entry : fightTeam.pets.entrySet()) {
				pets.put(entry.getKey(), new PetFighterVO().read(entry.getValue()));
			}
		}
		for (HeroFighter hero : fightTeam.getAllHero()) {
			heros.add(new HeroFighterVO().read(hero));
		}
		return this;
	}
}
